function init(){
	$(function(){
		var $log = $('#log');
		if (typeof web3 === 'undefined') {
			$log.append('<span class="label label-danger">错误：请在安装了MetaMask插件的Chrome浏览器中打开!</span>');
			return
		};
		if (web3.currentProvider.publicConfigStore.getState().networkVersion == '3') {
			$log.append('<span class="label label-success">当前环境是：</span><p>测试网</p>');
			adrx2018 = '0xd0f5157d0f199e911267f6f6416c9d044d45cb24';
		}else{
			$log.append('<span class="label label-success">当前环境是：</span><p>主网</p>');
		}
		
		var eth = new Web3(web3.currentProvider).eth;
		var account = '';
		eth.getAccounts(function(err, ac) {
			if (err) {
				$log.append('<span class="label label-danger">没有得到帐号</span>');
				return;
			};
			account = ac;
			$log.append('<span class="label label-success">当前帐号：</span><p>'+account+'</p>');
		});
		// 合约信息
		var $info = $('#infoBtn');
		$info.on('click', function(){
			$log.append('<span class="label label-info">正在查寻合约信息：</span><p></p>');
			var obj = web3.eth.contract(abix2018).at(adrx2018);
			obj.name.call(function(err, val) {
				$log.append('<p><span class="label label-default">合约名称：</span> '+val+'</p>');
			});
			obj.symbol.call(function(err, val) {
				$log.append('<p><span class="label label-default">合约符号：</span> '+val+'</p>');
			});
			obj.totalSupply.call(function(err, val) {
				$log.append('<p><span class="label label-default">合约Token数量：</span> '+val+'</p>');
			})
		})
		
		// 创建token
		var $tid = $('#tid');
		var $tval = $('#tval');
		var $crete = $('#crete');
		var $tprice = $('#tprice');
		var $tlis = $('.tli');
		var _star = 'mercury';
		$tlis.on('click', function(){
			var $this = $(this);
			_star = $this.attr('title');
			$tval.html(_star);
		});
		
		$crete.on('click', function(){
			var _tid = $tid.val();
			var _price = $tprice.val();
			var _user = '0x4DCC0836abFe2d46c07272dB482c5EEEe8e55127';
			var _update = account[0];
			console.log(_tid, _price, _user, _star, _update);
			if(_tid == '' || _price == '' || _user == '' || _star == '' || _update == ''){
				$log.append('<p><span class="label label-danger">参数错误!</span></p>');
				return;
			}
			$log.append('<span class="label label-info">正在创建中：</span><p></p>');
			var obj = web3.eth.contract(abix2018).at(adrx2018);
			obj.listItem.sendTransaction(_tid, _price, _user, _star, _update, function(err, hash) {
				if (err) {
					$log.append('<span class="label label-danger">发送交易失败!</span>');
					return;
				};
				$log.append('<p><span class="label label-success">创建成功，hash：</span> '+hash+'</p>');
				$log.append('<p><span class="label label-default">tip: </span><a href="https://ropsten.etherscan.io/tx/'+hash+'">订单记录查看地址</a></p>');
			})
		});
		
		// 取现
		var $price = $('#price');
		var $sub = $('#sub');
		$sub.on('click', function(){
			var _price = $price.val();
			if(_price == ''){
				$log.append('<p><span class="label label-danger">参数错误!</span></p>');
				return;
			}
			$log.append('<span class="label label-info">发送交易中：</span><p></p>');
			var obj = web3.eth.contract(abix2018).at(adrx2018);
			var config = {};
			console.log(_price);
			obj.withdrawAmount.sendTransaction(_price, config, function(err, hash) {
				if (err) {
					$log.append('<span class="label label-danger">发送交易失败!</span>');
					return;
				};
				log.append('<p><span class="label label-success">申请提现成功，hash：</span> '+hash+'</p>');
				$log.append('<p><span class="label label-default">tip: </span><a href="https://ropsten.etherscan.io/tx/'+hash+'">订单记录查看地址</a></p>');
			});
			
		});
	});
}



var adrx2018="0xe2178b5a8a308922c97c69f7354acff525f2f3d7";
var abix2018=[{ "constant": false, "inputs": [{ "name": "_admin", "type": "address" }], "name": "addAdmin", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" },
	{ "constant": false, "inputs": [{ "name": "_to", "type": "address" }, { "name": "_itemId", "type": "uint256" }], "name": "approve", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function"
}, { "constant": false, "inputs": [{ "name": "_itemId", "type": "uint256" }], "name": "buy", "outputs": [], "payable": true, "stateMutability": "payable", "type": "function" }, {
	"constant": false, "inputs": [], "name": "enableERC721", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, {
	"constant": false, "inputs": [{ "name": "_itemId", "type": "uint256" }, { "name": "_price", "type": "uint256" }, { "name": "_owner", "type": "address" }, { "name": "_itemName", "type": "bytes32" }, { "name": "_itemNameAddress", "type": "address" }], "name": "listItem", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, {
	"constant": false, "inputs": [{ "name": "_itemId", "type": "uint256" }], "name": "listItemFromRegistry", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, {
	"constant": false, "inputs": [{ "name": "_itemIds", "type": "uint256[]" }, { "name": "_price", "type": "uint256" }, { "name": "_owner", "type": "address" }, { "name": "_itemName", "type": "bytes32" }], "name": "listMultipleItems", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, {
	"constant": false, "inputs": [{ "name": "_itemIds", "type": "uint256[]" }], "name": "populateFromItemRegistry", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, {
	"constant": false, "inputs": [{ "name": "_admin", "type": "address" }], "name": "removeAdmin", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, {
	"constant": false, "inputs": [{ "name": "_itemId", "type": "uint256" }, { "name": "_itemName", "type": "bytes32" }], "name": "setItemName", "outputs": [], "payable": true, "stateMutability": "payable", "type": "function" }, {
	"constant": false, "inputs": [{ "name": "_itemRegistry", "type": "address" }], "name": "setItemRegistry", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, {
	"constant": false, "inputs": [{ "name": "_nick", "type": "string" }, { "name": "_countryname", "type": "string" }], "name": "setNick", "outputs": [], "payable": true, "stateMutability": "payable", "type": "function" }, {
	"anonymous": false, "inputs": [{ "indexed": true, "name": "_owner", "type": "address" }, { "indexed": true, "name": "_approved", "type": "address" }, { "indexed": false, "name": "_tokenId", "type": "uint256" }], "name": "Approval", "type": "event" }, {
	"anonymous": false, "inputs": [{ "indexed": true, "name": "_from", "type": "address" }, { "indexed": true, "name": "_to", "type": "address" }, { "indexed": false, "name": "_tokenId", "type": "uint256" }], "name": "Transfer", "type": "event" }, {
	"anonymous": false, "inputs": [{ "indexed": true, "name": "_nick", "type": "string" }, { "indexed": true, "name": "_countryName", "type": "string" }, { "indexed": true, "name": "_owner", "type": "address" }], "name": "SetNick", "type": "event" }, {
	"anonymous": false, "inputs": [{ "indexed": true, "name": "_itemId", "type": "uint256" }, { "indexed": true, "name": "_owner", "type": "address" }, { "indexed": false, "name": "_price", "type": "uint256" }], "name": "Sold", "type": "event" }, {
	"anonymous": false, "inputs": [{ "indexed": true, "name": "_itemId", "type": "uint256" }, { "indexed": true, "name": "_owner", "type": "address" }, { "indexed": true, "name": "_itemName", "type": "bytes32" }], "name": "ReNameEvent", "type": "event" }, {
	"anonymous": false, "inputs": [{ "indexed": true, "name": "_itemId", "type": "uint256" }, { "indexed": true, "name": "_owner", "type": "address" }, { "indexed": false, "name": "_price", "type": "uint256" }], "name": "Bought", "type": "event" }, {
	"anonymous": false, "inputs": [{ "indexed": true, "name": "_accountOfPrice", "type": "uint256" }, { "indexed": true, "name": "_owner", "type": "address" }], "name": "SetNickPrice", "type": "event" }, {
	"constant": false, "inputs": [{ "name": "_owner", "type": "address" }], "name": "setOwner", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, {
	"constant": false, "inputs": [{ "name": "_to", "type": "address" }, { "name": "_itemId", "type": "uint256" }], "name": "transfer", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, {
	"constant": false, "inputs": [{ "name": "_from", "type": "address" }, { "name": "_to", "type": "address" }, { "name": "_itemId", "type": "uint256" }], "name": "transferFrom", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, {
	"constant": false, "inputs": [], "name": "withdrawAll", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, {
	"constant": false, "inputs": [{ "name": "_amount", "type": "uint256" }], "name": "withdrawAmount", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_owner", "type": "address" }], "name": "accountOfN", "outputs": [{ "name": "_nick", "type": "string" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_owner", "type": "address" }], "name": "accountOfP", "outputs": [{ "name": "_nick", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_itemId", "type": "uint256" }], "name": "approvedFor", "outputs": [{ "name": "_approved", "type": "address" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_owner", "type": "address" }], "name": "balanceOf", "outputs": [{ "name": "_balance", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_price", "type": "uint256" }], "name": "calculateDevCut", "outputs": [{ "name": "_devCut", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_price", "type": "uint256" }], "name": "calculateNextPrice", "outputs": [{ "name": "_nextPrice", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_owner", "type": "address" }], "name": "countryofN", "outputs": [{ "name": "_nick", "type": "string" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [], "name": "implementsERC721", "outputs": [{ "name": "_implements", "type": "bool" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_admin", "type": "address" }], "name": "isAdmin", "outputs": [{ "name": "_isAdmin", "type": "bool" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_itemId", "type": "uint256" }], "name": "itemNameAddress", "outputs": [{ "name": "_itemNameAddress", "type": "address" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_itemId", "type": "uint256" }], "name": "itemNameOf", "outputs": [{ "name": "_itemName", "type": "bytes32" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_from", "type": "uint256" }, { "name": "_take", "type": "uint256" }], "name": "itemsForSaleLimit", "outputs": [{ "name": "_items", "type": "uint256[]" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [], "name": "name", "outputs": [{ "name": "_name", "type": "string" }], "payable": false, "stateMutability": "pure", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_itemId", "type": "uint256" }], "name": "nextPriceOf", "outputs": [{ "name": "_nextPrice", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_itemId", "type": "uint256" }], "name": "ownerOf", "outputs": [{ "name": "_owner", "type": "address" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_itemId", "type": "uint256" }], "name": "priceOf", "outputs": [{ "name": "_price", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_itemId", "type": "uint256" }], "name": "startingPriceOf", "outputs": [{ "name": "_startingPrice", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [], "name": "symbol", "outputs": [{ "name": "_symbol", "type": "string" }], "payable": false, "stateMutability": "pure", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_itemId", "type": "uint256" }], "name": "tokenExists", "outputs": [{ "name": "_exists", "type": "bool" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [{ "name": "_owner", "type": "address" }], "name": "tokensOf", "outputs": [{ "name": "_tokenIds", "type": "uint256[]" }], "payable": false, "stateMutability": "view", "type": "function" }, {
	"constant": true, "inputs": [], "name": "totalSupply", "outputs": [{ "name": "_totalSupply", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function"
}];


init();
